///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_CONTAINER_CSIMPLEBUFFER_H_
#define _BUOLA_CONTAINER_CSIMPLEBUFFER_H_

#include <buola/buola.h>
#include <buola/utility/ustorage.h>

namespace buola {

template<typename tType,std::size_t vCapacity=cDynamic,typename tAlloc=std::allocator<tType> >
class CSimpleBuffer : private UStorage<tType,vCapacity,0,tAlloc>
{
    typedef UStorage<tType,vCapacity,0,tAlloc> tStorage;

public:
    /// default constructor
    ///
    /// Initializes the buffer to be empty
    CSimpleBuffer()=default;

    /// constructor
    ///
    /// \p pCapacity specifies the size for dynamic buffers. This function is not valid for non-dynamic buffers.
    ///
    /// Initializes the buffer to be empty
    CSimpleBuffer(std::size_t pCapacity)
        :   tStorage(pCapacity)
    {}
    
    CSimpleBuffer(const CSimpleBuffer &pRH)=delete;
    CSimpleBuffer(CSimpleBuffer &&pRH)=default;
    CSimpleBuffer &operator=(const CSimpleBuffer &pRH)=delete;
    CSimpleBuffer &operator=(CSimpleBuffer &&pRH)=default;
    
    /// returns a pointer to the data
    size_t size() const         {   return tStorage::Capacity();    }

    /// returns a pointer to the data
    tType *begin()              {   return tStorage::Data();        }

    /// returns a pointer to the data
    tType *end()                {   return begin()+size();          }

    /// returns a pointer to the data
    const tType *begin() const  {   return tStorage::Data();        }

    /// returns a pointer to the data
    const tType *end() const    {   return begin()+size();          }
};

/*namespace buola*/ }

#endif
